package com.viser.partyinrs.listadapters;

import java.util.ArrayList;

import com.viser.partyinrs.R;
import com.viser.partyinrs.entities.Dogadjaj;


import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class DogadjajiListAdapter extends BaseAdapter {
	
	//adapter za prikaz liste dogadjaja
	
	ArrayList<Dogadjaj> dogadjaji;
	
	public DogadjajiListAdapter(ArrayList<Dogadjaj> dogadjaji, Activity context) {
		super();
		this.dogadjaji = dogadjaji;
		this.context = context;
	}

	Activity context;
	
	@Override
	public int getCount() {
		return dogadjaji.size();
	}

	@Override
	public Object getItem(int position) {
		return dogadjaji.get(position);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = context.getLayoutInflater();
		View layout = inflater.inflate(R.layout.dogadjaj_item, parent, false);
		
		TextView txtDogadjaj = (TextView) layout.findViewById(R.id.txtDogadjaj);
		TextView txtVremeDogadjaj = (TextView) layout.findViewById(R.id.txtVremeDogadjaj);
		//ImageView imgDogadjaj = (ImageView) layout.findViewById(R.id.imgDogadjaj);
		
		txtDogadjaj.setText(((Dogadjaj)getItem(position)).naziv);
		txtVremeDogadjaj.setText("od: " + ((Dogadjaj)getItem(position)).vremePocetak + " do: " + ((Dogadjaj)getItem(position)).vremeKraj);
		
		return layout;
	}

}
